﻿using System;
using System.Data.Entity.Spatial;

namespace ObjectMapper.Benchmark
{
    public class ObjectMapperExecutor : IMapExecutor
    {
        public string Name
        {
            get
            {
                return "ObjectMapper";
            }
        }

        public void Initialize()
        {
            ObjectMapper.Default.RegisterConverter((DbGeography source) => source);
            ObjectMapper.Default.RegisterConverter((DbGeometry source) => source);
        }

        public void PreExecute<TSource, TTarget>()
        {
            Mapper.Map<TSource, TTarget>(Activator.CreateInstance<TSource>());
        }

        public TTarget[] Execute<TSource, TTarget>(TSource[] entities)
        {
            return Mapper.Map<TSource, TTarget>(entities);
        }

        public void PostExecute<TSource, TTarget>()
        {
        }
    }
}
